package com.viptail.xiaogouzaijia.presenter.base;


import com.hannesdorfmann.mosby.mvp.MvpBasePresenter;
import com.viptail.xiaogouzaijia.api.BaseSubscriber;
import com.viptail.xiaogouzaijia.api.ExceptionHandle;
import com.viptail.xiaogouzaijia.view.base.BaseRetrofitView;

import rx.Subscriber;

/**
 * Created by FROG on 2016/11/10.
 */

public class BaseRetrofitPresenter<T> extends MvpBasePresenter<BaseRetrofitView<T>> {


    public Subscriber<T> subscriber = new BaseSubscriber<T>() {
        @Override
        public void onSuccess(T data) {
            if (isViewAttached()) {
                getView().onSuccess(data);
            }
        }

        @Override
        public void onFail(ExceptionHandle.ResponeThrowable e) {
            if (isViewAttached()) {
                getView().onFail(e);
            }
        }

        @Override
        public void onFinished() {
            if (isViewAttached()) {
                getView().onFinish();
            }
        }
    };

}
